@include("admin.layout.head")
<body>
<div class="x-body">
    <form  method="post" class="layui-form layui-form-pane">
        <table class="layui-tab" >

            <tr>
                <th>
                    属性
                </th>
                <th>
                    价格
                </th>
                <th>
                    库存
                </th>
            </tr>
            <tr>

                    <td style="border: 1px solid #0000F0">

                    </td>
                <td>

                </td>

                <td>

                </td>
            </tr>
        </table>
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="200">
                <col>
            </colgroup>

            <thead>
            <tr>
                <th>属性</th>
                <th>价格</th>
                <th>库存</th>
            </tr>
            </thead>
            @foreach($norms as $value)
            <tbody>
            <tr>
                <td>
                    @foreach($value as $norm)
                        {{$norm->name}}
                    @endforeach</td>
                <input type="hidden" name="norm_id[]" value="@foreach($value as $norm){{$norm->id}}|@endforeach">
                <td>
                    <input type="text" name="price[]" >
                </td>
                <td><input type="text" name="num[]" ></td>
            </tr>
            </tbody>
            @endforeach

        </table>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="add">增加</button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
        var layer = layui.layer;

        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data.field);
            $.ajax({
                url:"/admin/setKucunStore/{{$goods->id}}",
                type:"post",
                data:data.field,
                dataType:"json",
                success:function (msg) {
                    if(msg.error == 0){
                        layer.alert(msg.info, {icon: 6}, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }
                }
            });
            return false;
        });
    });
</script>

</body>

</html>

